package com.engine4cloud.tdf.education.convert;

import com.engine4cloud.tdf.common.core.util.CodeUtils;
import com.engine4cloud.tdf.education.dto.create.EduGroupCreateDTO;
import com.engine4cloud.tdf.education.dto.result.EduGroupResultDTO;
import com.engine4cloud.tdf.education.dto.update.EduGroupUpdateDTO;
import com.engine4cloud.tdf.education.entity.EduGroupEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;


@Mapper
public interface EduGroupConvert {
    EduGroupConvert INSTANCE = Mappers.getMapper(EduGroupConvert.class);

    EduGroupEntity createTo(EduGroupCreateDTO s);

    EduGroupEntity update(EduGroupUpdateDTO s);

    EduGroupResultDTO convert(EduGroupEntity s);

    default EduGroupEntity create(EduGroupCreateDTO s, Long tenantId) {
        EduGroupEntity entity = createTo(s);
        entity.setCode(CodeUtils.entrustCode());
        entity.setTenantId(tenantId);
        return entity;
    }
}
